package com.lovi.string_;

import javax.naming.Name;

/*
字符串占位符拼接
 */
public class String04 {
    public static void main(String[] args) {
        String name = "lovi";
        int age = 23;
        double score = 99.857;
        char gender = '女';
        //将所有的信息都拼接在一个字符串.
        String info =
                "我的姓名是" + name + "年龄是" + age + ",成绩是" + score + "性别是" + gender + "。希望大家喜欢我！";

        String formatStr = "我的姓名是%s,年龄是%d,成绩是%.2f,性别是%c。希望大家喜欢我！";
        String info2 = String.format(formatStr, name, age, score, gender);

        System.out.println(info);
        System.out.println(info2);
    }
}
